home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / Gui4Cli / Docs / Tutorials / ParseVar.gc < prev    next >
Text File  |  1997-12-02  |  2KB  |  70 lines

  1. G4C
  2.  
  3. ; ---- Parsing variables : splitting them into parts
  4.  
  5. winbig -1 -1 450 140 'ParseVar'
  6. wintype 11110001
  7. usetopaz
  8.  
  9. xonload
  10.  
  11. ; ---- The purpose of the list explained
  12.  
  13. lvuse ParseVar.gc 1
  14. lvadd 'The parts of'
  15. lvadd 'what you enter'
  16. lvadd 'will be listed'
  17. lvadd 'here.'
  18. guiopen ParseVar.gc
  19.  
  20. xonclose
  21. guiquit ParseVar.gc
  22.  
  23. ; ---- Header, and definition
  24.  
  25. Text 80 4 120 10 'Parsing a Variable' 20 NOBOX
  26. Text 20 30 160 10 'That means :' 28 NOBOX
  27. Text 40 50 160 10 'Splitting a variable' 28 NOBOX
  28. Text 40 60 160 10 'into its parts.' 28 NOBOX
  29.  
  30. ; ---- A listview to display the results of parsevar
  31.  
  32. xListView 290 14 150 90 'The parts' v '' 0 TXT
  33. gadid 1
  34.  
  35.  
  36. ; ---- some text to guide you down the right path..
  37.  
  38. Text 30 106 220 10 'Enter a few words here, and press <Return>.' 50 NOBOX
  39.  
  40. ; ---- Anything enter into the xTextIn gadget below will be parsed and the
  41. ;      results displayed in the listview.
  42.  
  43. xTextIn  10 120 400 16 '' entry '' 256
  44.  
  45. ; ---- This is the important line. The entry is parsed.
  46.  
  47. parsevar entry
  48.  
  49. ; ---- At this point, parse.total holds the number of words
  50. ;      in 'entry'.
  51. ;      Each word is contained in parse.1, parse.2, and so on.
  52. ;      $$parse.total, $$parse.1, etc are INTERNAL VARIABLES.
  53.  
  54. ;    Clear the list first
  55. lvclear
  56.  
  57. ;    Loop through the set of words, adding each one to 
  58. ;    the next line of the list.
  59.  
  60. setvar c 0
  61. while $c < $$parse.total   ; While our counter is less than the total
  62.    pp = '\$\$parse.$c'     ; Make the name of the next parse.n var
  63.    lvadd $pp               ; Add that name to the list
  64.    c == $c + 1             ; Increment the counter
  65. endwhile                   ; Done
  66.  
  67.  
  68.  
  69.  
  70.